<template>
	<view class="" v-if="flag">
		<web-view :src="'https://h5.syhy123.com/souhu_tlwx/?a='+a+'&param='+param"></web-view>
	</view>
	<view class="box" v-else>
		<image src="https://kshk.91bak.com/images/bk/t.png" mode="widthFix" style="width: 100%;"></image>
		<view class="d_f j_c_c">
			<image src="https://kshk.91bak.com/images/shbk/btn.png" mode="widthFix" style="width: 558rpx;margin-top: 30rpx;" @click="get"
				class="btn"></image>
		</view>
		<image src="https://kshk.91bak.com/images/shbk/b.png" mode="widthFix" style="width: 100%;"></image>
	</view>
</template>

<script>
	import {
		login,
		order,
		getAliUseridHjk,
		getshenhe,
		getMpUrl,
		getSignature,
		codeDecrypt

	} from '../../api/index.js'
	export default {
		data() {
			return {

				openidHF: "",
				a:'',
				param:"",
				flag:false
			}
		},
		components: {

		},
		methods: {
			gets() {
				wx.openCard({

					cardList: [

						{

							cardId: 'p9L_LwsGRoBKPs81ZyuixoJVoluw',

							code: uni.getStorageSync('kbcode')

						}

					],

					success: function(res) {

						console.log(res)

					},

					fail: function(res) {

						console.log(res)

					}

				})
			},

			get() {
				if (uni.getStorageSync('kbcode')) {
					wx.openCard({

						cardList: [

							{

								cardId: 'p9L_LwsGRoBKPs81ZyuixoJVoluw',

								code: uni.getStorageSync('kbcode')

							}

						],

						success: function(res) {

							console.log(res)

						},

						fail: function(res) {

							console.log(res)

						}

					})
				} else {
					getSignature({

						card_id: 'p9L_LwsGRoBKPs81ZyuixoJVoluw'

					}).then((res) => {
						console.log(res)
						wx.addCard({
							cardList: [{
								cardId: 'p9L_LwsGRoBKPs81ZyuixoJVoluw',
								cardExt: JSON.stringify({
									"timestamp": res.data.timestamp,
									"nonce_str": res.data.nonce_str,
									"signature": res.data.signature
								})
							}],
							success: (res) => {
								codeDecrypt({
									code: res.cardList[0].code
								}).then((rex) => {
									console.log(rex)
									if (rex.code) {
										uni.setStorageSync('kbcode', rex.data.code)
										wx.openCard({

											cardList: [

												{

													cardId: 'p9L_LwsGRoBKPs81ZyuixoJVoluw',

													code: rex.data.code

												}

											],

											success: function(res) {

												console.log(res)

											},

											fail: function(res) {

												console.log(res)

											}

										})
									}
								})
								console.log('领卡完成', res);

							},

							fail: (res) => {


								console.log(res, '不领卡')

							},
						})
					})
				}

			}

		},
		onLoad(option) {
if(option.param){
	this.param=option.param
}
if(option.a){
	this.a=option.a
}
			wx.hideHomeButton();
			if (!uni.getStorageSync('openidHF')) {
				wx.login({
					success(res) {

						if (res.code) {
							getAliUseridHjk({
								code: res.code,
								type: 3
							}).then((resx) => {
								console.log(resx)
								uni.setStorageSync('openidHF', resx.data.user_id)


							})
						} else {
							console.log('登录失败！' + res.errMsg)
						}
					}
				})
			}


var systemInfo = uni.getSystemInfoSync();
console.log(systemInfo,systemInfo.brand)

if (uni.getSystemInfoSync().brand == 'Xiaomi'||uni.getSystemInfoSync().brand == 'OPPO'||uni.getSystemInfoSync().brand == 'HUAWEI') {
    console.log('快应用');
	this.flag=true
} else  {
    console.log('当前非快');
	this.flag=false
}


		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped lang='scss'>
	@keyframes butChange {
		0% {
			transform: scale(1);
		}

		50% {
			transform: scale(1.1);
		}

		100% {
			transform: scale(1);
		}
	}

	.box {
		position: relative;
		background-color: #faeed4;
		min-height: 100%;
	}

	.btn {
		animation: butChange 1s infinite;
	}
</style>